<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%> 
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<c:set var="ctx" value="${pageContext.request.contextPath }" />
<jsp:include page="../inc.jsp" /> 
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<style type="text/css">
		table#formTb tr{
			height: 25px;
			border-bottom: 1px solid #d4d4d4;
			margin: 5px;
		}
		table#formTb tr td:first-child{
			text-align: right;
		}
		table#formTb tr td{
			padding: 7px 3px;
		}
	</style>
	<script type="text/javascript">
	    var $code = '',xz='商会';
		function selectPhoto(){
			$('#photo').click();
		}
		$(function(){
			$("#photo").change(function(e){
				this.name="photo";
				var file = e.target.files[0];
				//声明文件流对象
				var reader = new FileReader();
				//加载文件
				reader.onload = function(e){
					var img = $('#imgPhoto').attr("src",e.target.result);
				}
				reader.readAsDataURL(file);
			});
		});
		var si = '';
		
		function addCocsInfon(ln){
			$('#cocsInfo').html('');
			var tip = '';
			var isNow = '1',flat = true;
			for(var i=1;i<=ln;i++){
				if(i==ln){
					tip += "<br/><font style='color:red'>(当前届)</font>";
					isNow = '0';
					flat = false;
				}
				var str = ' <tr>'+
							'<th align="center">届次</th>'+
							'<th align="center">会长</th>'+
							'<th align="center">任职时间(会长)</th>'+
							'<th align="center">交接时间(会长)</th>'+
						'</tr>'+
						'<tr>'+
							'<th rowspan="3" align="center">'+
								'<input type="hidden" name="levleNum" value="'+i+'">'+
								'<input type="hidden" name="isNow" value="'+isNow+'">'+
								'第'+i+'届'+tip+
							'</th>'+
							'<td align="center">'+
								'<select class="easyui-combogrid" name="cocMemid" style="width:100px;"'+   
							        'data-options="required:true,    '+
							            'panelWidth:350, '+   
							            'idField:\'id\',    '+
							            'textField:\'name\',  '+  
							            'url:\'${ctx }/mc/find.coc\','+    
							            'columns:[[    '+
							            	'{field:\'ck\',checkbox:true,width:50},'+
							                '{field:\'name\',title:\'名称\',width:100},'+    
							                '{field:\'idcard\',title:\'身份证号码\',width:150}  '+ 
							            ']]    '+
							        '"></select> '+ 
							'</td>'+
							'<td align="center">'+
								'<input class="easyui-datebox" enable=false id="cocWorkdate"'+ 
									'value="${mb.cocWorkdate }"'+
									'name="cocWorkdate" data-options="required:true,width:100">'+
							'</td>'+
							'<td align="center">'+
								'<input class="easyui-datebox" enable=false id="cocConndate"'+ 
									'value="${mb.cocConndate }"'+
									'name="cocConndate" data-options="required:'+flat+',width:100">'+
							'</td>'+
						'</tr>'+
						'<tr>'+
							'<th align="center">秘书长</th>'+
							'<th align="center">任职时间(秘书长)</th>'+
							'<th align="center">交接时间(秘书长)</th>'+
						'</tr>'+
						'<tr>'+
							'<td align="center">'+
								'<select class="easyui-combogrid" name="secrMemid" style="width:100px;"'+   
							        'data-options="required:true,    '+
							            'panelWidth:350, '+   
							            'idField:\'id\',    '+
							            'textField:\'name\',  '+  
							            'url:\'${ctx }/mc/find.coc\','+    
							            'columns:[[    '+
							            	'{field:\'ck\',checkbox:true,width:50},'+
							                '{field:\'name\',title:\'名称\',width:100},'+    
							                '{field:\'idcard\',title:\'身份证号码\',width:150} '+  
							            ']]    '+
							        '"></select> '+
							'</td>'+
							'<td align="center">'+
								'<input class="easyui-datebox" enable=false id="secrWorkdate"'+ 
									'value="${mb.secrWorkdate }"'+
									'name="secrWorkdate" data-options="required:true,width:100">'+
							'</td>'+
							'<td align="center">'+
								'<input class="easyui-datebox" enable=false id="secrConndate"'+ 
									'value="${mb.secrConndate }"'+
									'name="secrConndate" data-options="width:100,required:'+flat+'">'+
							'</td>'+
						'</tr>';
				$('#cocsInfo').append(str);
				$.parser.parse('#cocsInfo');
			}
		}
		function getCode($code){
			$.ajax({
				type:'get',
				url:'${ctx}/pc/getCode/'+$code+'.coc',
				dataType:'json',
				success:function(r){
					$('#code').textbox('setValue',r);
				}
			});
		}
		
		function radioClick(obj){
			if(obj.value==0){
				url='${ctx }/pc/find.coc';
				xz = "商会";
			}else{
				url='${ctx }/ic/find.coc';
				xz = "协会";
			}
			$('#url').val(url);
			$('#cc02').combogrid('grid').datagrid('reload');
		}
	</script>
	<form id="cocsForm" enctype="multipart/form-data"> 
        <table id="formTb" width="100%">
        	<tr height="130px">
				<th align="center" colspan="2" style="padding:5px">
					<img id="imgPhoto" alt="" 
					<c:if test="${not empty mb.id }">src="${ctx }/fc/getImg.coc?tname=t_coc_member&tid=${mb.id }"</c:if>
        	        <c:if test="${empty mb.id }">src="${ctx }/img/i07.png"</c:if> 
					style="width: 120px;height: 120px;
					border-radius: 120px;border:1px solid #d4d4d4;
					cursor: pointer;" onclick="selectPhoto()"/>
					<input
					type="file"
					id="photo" style="display: none" accept="image/jpeg,image/png"/>
					<input type="hidden" name="id" value="${mb.id }">
				</th>
				
			</tr>
			<tr>
				<td width="100px">商协会性质:</td>
				<td>
					<input type="radio" name="xz" value="0" checked onclick="radioClick(this)">商会
					<input type="radio" name="xz" value="1" onclick="radioClick(this)">协会
				</td>
			</tr>
			<tr>
				<td width="100px">注册地:</td>
				<td>
					<select id="cc01" class="easyui-combogrid" name="regiaddrId" 
						style="width:250px"  
	    				data-options="
	    					required:true,
		    				idField:'code',
		    				textField:'name',
		    				url:'${ctx }/pc/find.coc',
		    				columns:[[  
		    					{field:'ck',checkbox:true},  
				                {field:'code',title:'编码',width:70},    
				                {field:'name',title:'名称',width:150}    
				            ]],
				            width:220,
				            onChange:function(n,o){
				            	rid = n;
				            	r01 = $('#cc01').combogrid('grid').datagrid('getSelected');
				            	sn01 = r01.smallName;
				            	$('#cc02').combogrid('setValue','');
				            	$('#cc02').combo('readonly', false);
				                
				            }   
			        	"></select>
				</td>
			</tr>
			<tr>
				<td width="100px">所属地(行业):</td>
				<td>
					<select id="cc02" class="easyui-combogrid" name="territoryId" 
						style="width:250px"  
	    				data-options="
	    					required:true,
	    					readonly:true,
		    				idField:'code',
		    				textField:'name',
		    				url:'',
		    				columns:[[  
		    					{field:'ck',checkbox:true},  
				                {field:'code',title:'编码',width:70},    
				                {field:'name',title:'名称',width:150}    
				            ]],
				            width:220,
				            onShowPanel:function(){
				            	url = $('#url').val();
				            	$('#cc02').combogrid('grid').datagrid('options').url = url;
								$('#cc02').combogrid('grid').datagrid('reload');
								$('#cc02').combogrid('grid').datagrid('load',{sex:rid});
				            },
				            onChange:function(n,o){
				            	tid = n;
				            	$code ='142'+rid+tid;
				            	getCode($code);
				            	r02 = $('#cc02').combogrid('grid').datagrid('getSelected');
				            	sn02 = r02.smallName;
				            	$('#name').textbox('setValue',sn01+sn02+xz);
				            }   
			        	"></select>
			        <input type="hidden" id="url" value="${ctx }/pc/find.coc">	
				</td>
			</tr>
			<tr>
				<td>商会编码:</td>
				<td>
					<input class="easyui-textbox" id="code" name="code" value="${mb.code}" data-options="
						required:true,
						prompt:'注册地编码+所属地(行业)编码+6位自然码组成',
						width:250
					">
				</td>
			</tr>
			<tr>
				<td>商会名称:</td>
				<td>
					<input class="easyui-textbox" id="name" name="name" value="${mb.name}" data-options="
						required:true,
						prompt:'注册地+所属地(行业)组成',
						width:250
					">
				</td>
			</tr>
			<tr>
				<td>上级商(协)会:</td>
				<td>
					<input id="cc07" name="parentId" 
					class="easyui-combotree" style="width:250px;"   
					value="<c:if test="${empty m.parentId }">0</c:if>
					<c:if test="${not empty m.parentId }">${m.parentId}</c:if>"
        				data-options="
        				url:'${ctx }/cc/find.coc',
        				parentField:'parentId',
        				required: true 
        				"> 
				</td>
			</tr>
			<tr>
				<td>成立时间:</td>
				<td>
					<input class="easyui-datebox" enable=false id="buildDate" 
					value="${mb.buildDate }"
					name="buildDate" data-options="width:250">
				</td>
			</tr>
			<tr>
				<td valign="top">当前届次:</td>
				<td>
					<input class="easyui-numberspinner" id="levelNum" name="levelNum" value="${mb.levelNum }" data-options="
						required:true,
						prompt:'指当前第几届',
						min:1,
						editable:false,
						width:250,
						onChange:function(){
							var ln = $('#levelNum').numberspinner('getValue');      
							addCocsInfon(ln);
						}
					">
					<table id="cocsInfo">
					</table>
				</td>
			</tr>
			<tr>
				<td>联系人:</td>
				<td>
					<input class="easyui-textbox" name="contact" data-options="
						width:250
					">
				</td>
			</tr>
			
			
			<tr>
				<td>联系电话:</td>
				<td>
					<input class="easyui-textbox" name="phone" data-options="
						required:true,
						prompt:'手机号码或座机号码',
						width:250
					">
				</td>
			</tr>
			<tr>
				<td>办公地址:</td>
				<td>
					<input class="easyui-textbox" value="${mb.workAddr }"  
					name="workAddr" style="width: 250px" >
				</td>
			</tr>
			<tr>
				<td>微信:</td>
				<td>
					<input class="easyui-textbox" value="${mb.wechat }"  
					name="wechat" style="width: 250px" >
				</td>
			</tr>
			<tr>
				<td>网站地址:</td>
				<td>
					<input class="easyui-textbox" value="${mb.url }"  
					name="url" style="width: 250px" >
				</td>
			</tr>
			<tr>
				<td>简介:</td>
				<td>
					<input class="easyui-textbox" value="${mb.content }" 
					multiline=true name="content" style="height: 50px;width: 250px" >
				</td>
			</tr>
		</table>   
	</form>
</body>
</html>